package com.soft.line.auth;

/**
 * @author 86185
 * @date 2020/5/13 10:57
 */
public class StrUtil {

    /**
     * 拼接字符串
     *
     * @param str    需拼接字符串
     * @param params 替换str中的{}字符参数
     * @return str
     */
    public static String spliceStr(String str, Object... params) {
        StringBuilder builder = new StringBuilder(str.length() + 30);
        int i = 0;
        int j;
        for (Object param : params) {
            j = str.indexOf("{}", i);
            if (j != -1) {
                builder.append(str, i, j);
                builder.append(param);
                i = j + 2;
            } else {
                break;
            }
        }
        builder.append(str, i, str.length());

        return builder.toString();
    }

}
